﻿using Lightworks.Core.Entity;
using Lightworks.Core.Repository;
using Lightworks.Core.Service;
using Lightworks.System.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lightworks.System.Services.Impl
{
    [Service]
    public class DepartmentService : IDeptService
    {
        private readonly SugarRepository<Department> repo;

        public DepartmentService(SugarRepository<Department> repo) 
        {
            this.repo = repo;
        }

        public List<Department> GetAll()
        {
            return repo.GetList().List2Tree();
        }

        public bool Remove(long[] ids)
        {
            return repo.Delete(x => ids.Contains(x.Id));
        }

        public bool Save(Department dept)
        {
            return repo.InsertOrUpdate(dept);
        }
    }
}
